using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using System;
using System.Collections;
using System.IO;
using System.Reflection;
public class PayOrderUtil
{
	private static ArrayList arrayList_0;
	private static object object_0 = Missing.Value;
	public static bool smethod_0(string string_0, string string_1, ArrayList arrayList_1, out string string_2)
	{
		HSSFWorkbook hSSFWorkbook = null;
		new ArrayList();
		bool result;
		try
		{
			FileStream fileStream = new FileStream(string_0, FileMode.Open, FileAccess.Read);
			hSSFWorkbook = new HSSFWorkbook(fileStream);
			ISheet sheetAt = hSSFWorkbook.GetSheetAt(0);
			int num = 1;
			foreach (GClass26 gClass in arrayList_1)
			{
				PayOrderUtil.smethod_4(sheetAt, num, 0, gClass.string_0);
				PayOrderUtil.smethod_4(sheetAt, num, 1, gClass.string_1);
				PayOrderUtil.smethod_4(sheetAt, num, 2, gClass.string_2);
				num++;
			}
			if (File.Exists(string_1))
			{
				File.Delete(string_1);
			}
			fileStream = new FileStream(string_1, FileMode.CreateNew, FileAccess.Write);
			hSSFWorkbook.Write(fileStream);
			fileStream.Flush();
			fileStream.Close();
			string_2 = "";
			result = true;
		}
		catch (Exception ex)
		{
			string_2 = ex.ToString();
			result = false;
		}
		finally
		{
			PayOrderUtil.smethod_8(hSSFWorkbook);
		}
		return result;
	}
	public static ArrayList smethod_1(string string_0, out string string_1)
	{
		HSSFWorkbook hSSFWorkbook = null;
		ArrayList arrayList = new ArrayList();
		ArrayList result;
		try
		{
			FileStream s = new FileStream(string_0, FileMode.Open, FileAccess.Read);
			hSSFWorkbook = new HSSFWorkbook(s);
			ISheet sheetAt = hSSFWorkbook.GetSheetAt(0);
			PayOrderUtil.smethod_2(sheetAt);
			int num = 1;
			while (!PayOrderUtil.smethod_5(sheetAt, num, 1).Equals(""))
			{
				arrayList.Add(new PayOrder
				{
					taobaoTradeParentId = PayOrderUtil.smethod_5(sheetAt, num, PayOrderUtil.smethod_3("订单编号")),
					num_iid = PayOrderUtil.smethod_5(sheetAt, num, PayOrderUtil.smethod_3("商品ID")),
					title = PayOrderUtil.smethod_5(sheetAt, num, PayOrderUtil.smethod_3("商品信息")),
					shop_title = PayOrderUtil.smethod_5(sheetAt, num, PayOrderUtil.smethod_3("所属店铺")),
					payStatus = PayOrderUtil.smethod_7(PayOrderUtil.smethod_5(sheetAt, num, PayOrderUtil.smethod_3("订单状态"))),
					auctionNum = PayOrderUtil.smethod_5(sheetAt, num, PayOrderUtil.smethod_3("商品数")),
					totalAlipayFeeString = PayOrderUtil.smethod_5(sheetAt, num, PayOrderUtil.smethod_3("付款金额")),
					feeString = PayOrderUtil.smethod_5(sheetAt, num, PayOrderUtil.smethod_3("效果预估")),
					discountAndSubsidyToString = PayOrderUtil.smethod_5(sheetAt, num, PayOrderUtil.smethod_3("收入比率")),
					createTime = PayOrderUtil.smethod_5(sheetAt, num, PayOrderUtil.smethod_3("创建时间")),
					earningTime = PayOrderUtil.smethod_5(sheetAt, num, PayOrderUtil.smethod_3("结算时间")),
					adzone_name = PayOrderUtil.smethod_5(sheetAt, num, PayOrderUtil.smethod_3("广告位名称")),
					terminalType = PayOrderUtil.smethod_5(sheetAt, num, PayOrderUtil.smethod_3("成交平台"))
				});
				num++;
			}
			string_1 = "";
			result = arrayList;
		}
		catch (Exception ex)
		{
			string_1 = ex.ToString();
			result = null;
		}
		finally
		{
			PayOrderUtil.smethod_8(hSSFWorkbook);
		}
		return result;
	}
	private static void smethod_2(ISheet isheet_0)
	{
		PayOrderUtil.arrayList_0 = new ArrayList();
		int int_ = 0;
		string text = PayOrderUtil.smethod_5(isheet_0, 0, int_);
	}
	private static int smethod_3(string string_0)
	{
		for (int i = 0; i < PayOrderUtil.arrayList_0.Count; i++)
		{
			if (string_0.Equals((string)PayOrderUtil.arrayList_0[i]))
			{
				return i;
			}
		}
		return 1;
	}
	private static bool smethod_4(ISheet isheet_0, int int_0, int int_1, string string_0)
	{
		IRow row = isheet_0.GetRow(int_0);
		if (row == null)
		{
			row = isheet_0.CreateRow(int_0);
		}
		ICell cell = row.GetCell(int_1);
		if (cell == null)
		{
			cell = row.CreateCell(int_1);
		}
		cell.SetCellValue(string_0);
		return true;
	}
	private static string smethod_5(ISheet isheet_0, int int_0, int int_1)
	{
		IRow row = isheet_0.GetRow(int_0);
		if (row == null)
		{
			return "";
		}
		return PayOrderUtil.smethod_6(row.GetCell(int_1));
	}
	private static string smethod_6(ICell icell_0)
	{
		if (icell_0 == null)
		{
			return null;
		}
		switch (icell_0.CellType)
		{
		case CellType.Numeric:
			return string.Concat(icell_0.NumericCellValue);
		case CellType.String:
			return icell_0.StringCellValue;
		case CellType.Blank:
			return "";
		case CellType.Boolean:
			return string.Concat(icell_0.BooleanCellValue);
		case CellType.Error:
			return string.Concat(icell_0.ErrorCellValue);
		}
		return icell_0.ToString();
	}
	public static string smethod_7(string string_0)
	{
		if (string_0.Equals("订单创建"))
		{
			return "11";
		}
		if (string_0.Equals("订单付款"))
		{
			return "12";
		}
		if (string_0.Equals("订单失效"))
		{
			return "13";
		}
		if (string_0.Equals("订单成功"))
		{
			return "14";
		}
		if (string_0.Equals("订单结算"))
		{
			return "3";
		}
		return "0";
	}
	private static void smethod_8(HSSFWorkbook hssfworkbook_0)
	{
		try
		{
			if (hssfworkbook_0 != null)
			{
				hssfworkbook_0.Close();
				hssfworkbook_0 = null;
			}
		}
		catch
		{
		}
	}
}
